//
//  SetupViewController.m
//  DianDangDai
//
//  Created by bhf on 2017/12/19.
//  Copyright © 2017年 bhf. All rights reserved.
//

#import "SetupViewController.h"
#import "SetupCell.h"
@interface SetupViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, strong) NSArray *imageArrray;
@property (nonatomic, strong) NSArray *detailTitleArray;
@end

@implementation SetupViewController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    _titleArray = @[@"绑定手机",@"实名认证",@"密码管理",@"我的银行卡"];
    _imageArrray = @[@"sz1",@"sz2",@"sz3",@"sz4"];
    _detailTitleArray = @[@"未绑定",@"未认证",@"修改",@""];
    self.title = @"安全设置";
    self.navigationItem.backBarButtonItem = BarButtonItem;
    // Do any additional setup after loading the view.
}
//setup_cell
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    SetupCell *cell = [tableView dequeueReusableCellWithIdentifier:@"setup_cell" forIndexPath:indexPath];
    cell.image.image = [UIImage imageNamed:_imageArrray[indexPath.section]];
    cell.lab1.text = self.titleArray[indexPath.section];
    cell.lab2.text = self.detailTitleArray[indexPath.section];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *identifier;
    switch (indexPath.section) {
        case 0:
            identifier = @"phone";
            break;
        case 1:
            identifier = @"realName";
            break;
        case 2:
            identifier = @"password";
            break;
        case 3:
            identifier = @"bankCard";
            break;
        default:
            break;
    }
    
   
        //phone
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"My" bundle:[NSBundle mainBundle]];
        UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:identifier];
        viewController.hidesBottomBarWhenPushed = YES;
        
        [self showViewController:viewController sender:self];
  
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    return view;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0)];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0;
}
- (IBAction)exit:(UIButton *)sender {
    UIViewController *vc = [LOGIN_STORYBOARD instantiateViewControllerWithIdentifier:@"alc"];
    NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
    [df synchronize];
    [df setObject:@"No" forKey:@"login"];
    [df removeObjectForKey:@"userInformation"];
    [self presentViewController:vc animated:YES completion:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
